// Domien Nowicki
#include "QtTranslateToEffect.h"
#include "QtSprite.h"

QtTranslateToEffect::QtTranslateToEffect(): target(0)
{
}

QtTranslateToEffect::~QtTranslateToEffect()
{
}

QtTranslateToEffect::QtTranslateToEffect(const QtTranslateToEffect& rhs): QtSingleAnimationEffect(rhs), target(rhs.target), endPosition(rhs.endPosition), startPosition(rhs.startPosition)
{

}


void QtTranslateToEffect::SetTarget(QtSprite *sprite)
{
	target = sprite;
}

QtSprite* QtTranslateToEffect::Target() const
{
	return target;
}

void QtTranslateToEffect::Update(qreal value)
{
	if (target)
	{	
		target->SetCenterPoint( startPosition + (endPosition-startPosition)*value );
	}
}

void QtTranslateToEffect::SetEndPosition(const QPointF& position)
{
	endPosition = position;
}

void QtTranslateToEffect::SetupAnimation()
{
	startPosition = target->CenterPoint();
}

QtAnimationEffect* QtTranslateToEffect::Clone() const
{
	return new QtTranslateToEffect(*this);
}

